package com.hyz.login.mapper;

import com.hyz.login.model.Pharmacy;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zwq
 * @since 2022-11-21
 */
public interface PharmacyMapper extends BaseMapper<Pharmacy> {


    List<Pharmacy> findAll(@Param("durgname") String durgname,
                           @Param("page") Integer page,
                           @Param("limit") Integer limit);

    @Update("update pharmacy set drugstorenum = drugstorenum-#{drugstorenum} where pharmacyName = #{pharmacyName}")
    Integer modifyDrugstorenum(@Param("pharmacyName") String pharmacyName,
                               @Param("drugstorenum") Integer drugstorenum);

    @Update("update pharmacy set drugstorenum = drugstorenum+#{drugstorenum} where pharmacyName = #{pharmacyName}")
    Integer addDrugstorenum(@Param("pharmacyName") String pharmacyName,
                               @Param("drugstorenum") Integer drugstorenum);

    @Select("select pharmacyName,drugstorenum,sellingPrice from pharmacy where pharmacyId = #{pharmacyId}")
    Pharmacy findNumById(@Param("pharmacyId") Integer pharmacyId);

}
